package com.boolib;

import java.util.concurrent.*;

public class Call {
    public static void main(String[] args) throws ExecutionException, InterruptedException {

        LinkedBlockingQueue linkedBlockingQueue = new LinkedBlockingQueue<Runnable>(2);
        ExecutorService executorService = new ThreadPoolExecutor(2,25,20L,TimeUnit.SECONDS,linkedBlockingQueue);



        for(int i = 0 ;i<100;i++){
            Future future = executorService.submit(new Th01());
            System.out.println("活动"+((ThreadPoolExecutor) executorService).getActiveCount());
          //  System.out.println("队列"+linkedBlockingQueue.size());
        }

        //        ScheduledExecutorService executor  = new ScheduledThreadPoolExecutor(1);
//
//            executor.schedule(new Th01(),2L,TimeUnit.SECONDS);

    }
}

class Th01 implements  Callable<String>{



    public String call() throws Exception {


        String a = "aaa";
        Thread.sleep(4000);
        StringBuffer stringBuffer = new StringBuffer();
        stringBuffer.append(a);
        for (int i = 0 ; i < 200 ;i++)
        {

            stringBuffer.append(1);
        }
        System.out.println(Thread.currentThread().getName());
        return   stringBuffer.toString();
    }
}
